const fs = require('fs');
const Cookies = require('cookies');

let findFile = function (fileName) {

};

let findAllFiles = function (req) {
    let fileList = [];
    let fileClassification = 'images';
    let cookies = new Cookies(req,{});
    let id = cookies.get('id');
    switch (fileClassification) {
        case 'images':
            listFiles(fileClassification+'/'+id+"/",fileList);
            break;
        default:
            break;
    }
    return fileList;
};

let listFiles = function(path,fileList){
    let files = fs.readdirSync(path);
    files.forEach(function (item, index) {
        let stat = fs.statSync(path+item);
        if (stat.isDirectory()){
            listFiles(path+item+'/',fileList)
        } else{
            fileList.push(item)
        }
    })
};

module.exports.findAllFiles = findAllFiles;

